package net.oschina.allchat.protocol.core;

import net.oschina.allchat.protocol.Constants;
import net.oschina.allchat.protocol.HandyUtils;

public final class LangText {
	private String lang;
	private String text;
	
	public static final String PREFIX_LANG_TEXT = Constants.NAMESPACE_ALLCHAT;
	public static final String LOCAL_NAME_LANG_TEXT = "lang";
	
	public LangText() {
		this(null);
	}
	
	public LangText(String text) {
		this.text = text;
	}
	
	public LangText(String text, String lang) {
		this.text = text;
		this.lang = lang;
	}
	
	public String getLang() {
		return lang;
	}
	
	public void setLang(String lang) {
		this.lang = lang;
	}
	
	public String getText() {
		return text;
	}
	
	public void setText(String text) {
		this.text = text;
	}
	
	@Override
	public int hashCode() {
		int hash = 7;
		
		hash += 31 * hash + (lang == null ? 0 : lang.hashCode());
		hash += 31 * hash + (text == null ? 0 : text.hashCode());
		return hash;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof LangText) {
			LangText other = (LangText)obj;
			
			return HandyUtils.equalsEvenNull(lang, other.lang) &&
					HandyUtils.equalsEvenNull(text, other.text);
		}
		
		return false;
	}
}
